package csel.view;
import java.awt.Graphics;
import java.awt.Point;

import csel.model.*;
/**
 * Renders the tiles on a map
 * @author Ryan
 *
 */
public class TileRenderer 
{
	private Map map;
	private ObjectRepresentor objRep;
	private RepresentationFactory repFact;
	/**
	 * Constructor
	 */
	public TileRenderer(Map map)
	{
		this.map = map;
		repFact = RepresentationFactory.getInstance();
	}
	public void renderTiles(Graphics g, Tile t[][]){
		Positioner pos = new Positioner();
		Point p;
		Location ref;
		ref = new Location(0, 0);
		for (int i = 0; i < t.length; i++)
		{
			for (int j = 0; j < t[i].length; j++)
			{
				p = pos.convertLocation(ref, new Location(i, j));
				if (t[i][j] != null)
				{
					objRep = repFact.get(t[i][j].getTerrain());
					objRep.draw(g, p);
					objRep = repFact.get(t[i][j].getDecal());
					objRep.draw(g, p);
					objRep = repFact.get(t[i][j].getItem());
					objRep.draw(g, p);
					objRep = repFact.get(t[i][j].getEntity());
					objRep.draw(g, p);
				}

			}
		}
	}
}
